<?php

declare(strict_types=1);

namespace App\Resource\Activity\Flower\RoomRank;

use App\Enums\RoomEnum;
use Illuminate\Http\Resources\Json\JsonResource;

class Resource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'rank'         => $this->rank ?? null,
            'sum_price'    => (int)$this->sum_price ?? null,
            'is_show_rank' => $this->is_show_rank ?? null,
            'room_id'      => $this->user_room->id ?? null,
            'room_code'    => $this->user_room->room_id ?? null,
            'room_name'     => $this->user_room->room_name ?? null,
            'cover_picture' => (isset($this->user_room->cover_picture)&&$this->user_room->cover_picture)?$this->user_room->cover_picture: RoomEnum::ROOM_DEFAULT_COVER,
            'is_followed'  => $this->followed,  // 是否已经关注该房间
            'range'        => $this->range,
        ];
    }
}
